package com.share.user.api.factory;

import com.share.common.core.exception.ServiceException;
import com.share.user.api.RemoteUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 用户服务降级处理
 *
 * @author YC
 */
@Component
public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteUserFallbackFactory.class);

    @Override
    public RemoteUserService create(Throwable throwable) {
        log.error("服务调用失败:{}", throwable.getMessage());
//        return new RemoteUserService() {
//            @Override
//            public R<UserInfo> wxLogin(String code) {
//                return null;
//            }
//
//            @Override
//            public R<UserInfo> getInfo(Long id) {
//                return null;
//            }
//
//            @Override
//            public R getUserCount() {
//                return null;
//            }
//        };
        throw new ServiceException("服务调用出现错误，降级方法抛出异常");
    }

}
